package com.ruoyi.web.controller.byManager;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ByJz;
import com.ruoyi.system.service.IByJzService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 家长管理Controller
 *
 * @author ruoyi
 * @date 2023-05-29
 */
@RestController
@RequestMapping("/by/jz")
public class ByJzController extends BaseController
{
    @Autowired
    private IByJzService byJzService;

    /**
     * 查询家长管理列表
     */
    @PreAuthorize("@ss.hasPermi('by:jz:list')")
    @GetMapping("/list")
    public TableDataInfo list(ByJz byJz)
    {
        startPage();
        List<ByJz> list = byJzService.selectByJzList(byJz);
        return getDataTable(list);
    }

    /**
     * 导出家长认证列表
     */
    @PreAuthorize("@ss.hasPermi('by:jz:export')")
    @Log(title = "家长管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ByJz byJz)
    {
        List<ByJz> list = byJzService.selectByJzList(byJz);
        ExcelUtil<ByJz> util = new ExcelUtil<ByJz>(ByJz.class);
        util.exportExcel(response, list, "家长认证数据");
    }

    /**
     * 获取家长管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('by:jz:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(byJzService.selectByJzById(id));
    }

    /**
     * 新增家长认证
     */
    @PreAuthorize("@ss.hasPermi('by:jz:add')")
    @Log(title = "家长管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ByJz byJz)
    {
        return toAjax(byJzService.insertByJz(byJz));
    }

    /**
     * 修改家长管理
     */
    @PreAuthorize("@ss.hasPermi('by:jz:edit')")
    @Log(title = "家长管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ByJz byJz)
    {
        return toAjax(byJzService.updateByJz(byJz));
    }

    /**
     * 删除家长认证
     */
    @PreAuthorize("@ss.hasPermi('by:jz:remove')")
    @Log(title = "家长管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(byJzService.deleteByJzByIds(ids));
    }
}

